<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>{:$page_info['title']}</title>
<link rel="icon" href="favicon.ico" type="image/ico">

<meta name="author" content="yinqi">
<link href="__STATIC__/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/style.min.css" rel="stylesheet">

<link href="__STATIC__/common/select2/select2.css" rel="stylesheet">
<link href="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">

<link href="__STATIC__/common/datatables/jquery.datatables.css" rel="stylesheet">

<link href="__STATIC__/admin/css/cch.css" rel="stylesheet">
</head>
  
<body>
<div class="container-fluid p-t-15">
    <div class="input-group col-lg-2">
        <span class="input-group-btn"><button class="btn btn-default" type="button">日期</button></span>
        <select class="form-control" id="model_date_sel">
            <?php foreach ($model_dates as $param_k => $param_v): ?>
                <option value="{:$param_v['key']}" {:$param_v['key']==session('bill_model_date')?'selected':''}>{:$param_v['name']}</option>
            <?php endforeach ?>
        </select>
    </div>
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar clearfix">
          <form class="pull-right search-bar" method="get" action="{:url($page_info['action'])}" role="form">
            {include file="html/search" /}
          
          </form>
          <div class="toolbar-btn-action">
            <!-- <a class="btn btn-info m-r-5 export_btn" href="javascript:void(0)"><i class="mdi mdi-arrow-collapse-down"></i> 导出</a> -->
            <a class="btn btn-success m-r-5 search_btn" href="javascript:void(0)"><i class="mdi mdi-magnify"></i> 搜索</a>
          </div>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <?php if (empty($list)): ?>
            <table class="table table-bordered" >
                <tr><td colspan="100" class="text-center">暂无数据</td></tr>
            </table>
            <?php else: ?>
            <table class="table table-bordered" id="table1">
              <thead>
                <tr>
                    <th>客户名称</th>
                    <th>当前余额</th>
                    <th>原价</th>
                    <th>平台成本</th>
                    <th>实付金额</th>
                </tr>
              </thead>
              <tbody>
                    <?php foreach ($list as $k => $vo): ?>
                    <tr>
                        <td>{:$vo['customer_name']}</td>
                        <td>{:$vo['balance_money']}</td>
                        <td>{:$vo['pretax_gross_amount']}</td>
                        <td>{:$vo['pretax_amount']}</td>
                        <td>{:$vo['platform_amount']}</td>
                    </tr>
                    <?php endforeach ?>
              </tbody>
              <tfoot>
                    <tr> 
                        <td>总计</td>
                        <td>{:array_sum(array_column($list, 'balance_money'))}</td>
                        <td>{:array_sum(array_column($list, 'pretax_gross_amount'))}</td>
                        <td>{:array_sum(array_column($list, 'pretax_amount'))}</td>
                        <td>{:array_sum(array_column($list, 'platform_amount'))}</td>
                    </tr>
              </tfoot>
            </table>
            <?php endif ?>
          </div>


 
        </div>
      </div>
    </div>
    
  </div>
  
</div>

<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>

<!-- 时间选择器 -->
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/moment.min.js"></script>
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/admin/js/bootstrap-datetimepicker/locale/zh-cn.js"></script>

<script src="__STATIC__/common/select2/select2.min.js"></script><!-- 下拉搜索 -->

<script src="__STATIC__/common/datatables/jquery.datatables.min.js"></script><!-- 下拉搜索 -->

<script type="text/javascript" src="__STATIC__/admin/js/lyear-loading.js"></script><!-- loading -->
<script type="text/javascript" src="__STATIC__/admin/js/cch.js"></script>
<script type="text/javascript">
    jQuery('#table1').dataTable({
         "bPaginate" : false,
         "bLengthChange":false,
         "bFilter" : false,
         "bSort" : true,
         "bInfo": false,
         "aaSorting": [[1, "desc"]], 
         "aoColumnDefs": [{ //给每个单独的列设置不同的填充，或者使用aoColumns也行
                  "aTargets": [0],
                  "bSortable": false
              }
        ],

    });

    $("#model_date_sel").on('change',function(){
        var l = $('body').lyearloading({
            opacity: 0.5,
            spinnerSize: 'lg',
            spinnerText: '刷新中',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        window.location.href = '{:url('selDate',[],'')}?page=statistics&key='+$(this).val();
    });
</script>
</body>
</html>